define(['dojo/_base/declare'],function(declare){
    'use strict';

  	return declare("Prediction",null,{
    	constructor: function() {
			this.html=
            '<div>' +
//	    	'<div class="panel panel-info">'+
//			'<div class="panel-heading">'+
//				'<h3 class="panel-title">预报预警</h3>'+
//			'</div>'+
			'<div class="layui-tab">'+
				'<ul class="layui-tab-title" id="prediction-Tab">' +
    				'<li class="active"> <a href="#prediction-signal" data-toggle="tab">预警信号</a></li>' +
    				'<li><a href="#prediction-warning" data-toggle="tab">预警</a></li>' +
    			'</ul >' +
				'<div class="layui-tab-content">' +
					'<div class="layui-tab-item layui-show" id="prediction-signal"><div id="prediction-signalTable"></div></div>' +
					'<div class="layui-tab-item" id="prediction-warning"><div id="prediction-warningTable"></div></div>' +
				'</div >' +
			'</div>'+
			'<button class="layui-btn layui-btn-primary layui-btn-fluid" id="prediction-more" style="float:left;bottom:0;"><i class="layui-icon" style="color: #1E9FFF;">&#xe61a;</i>更多</button>' +
	    	'</div>'+ 
            '</div>' +
            '<div class="modal fade" id="myModal">' +
                '<div class="modal-dialog" style="width:940px;">' +
                    '<div class="modal-content">' +
                    ' <!-- 模态框头部 -->' +
                    '<div class="modal-header">' +
                    '<h5 class="modal-title">预警详情</h5>' +
                '<button type="button" class="close" data-dismiss="modal">&times;</button>' +
                '</div>' +
                '<!-- 模态框主体 -->' +
                '<div class="modal-body" id="preview-msg">' +
                    '<div class="lightbox"></div>' +
                        '<div id="pop" class="pop">' +
                            '<canvas id="the-canvas"></canvas>' +
                        '</div>' +
                '</div>' +
                '<!-- 模态框底部 -->' +
                '<div class="modal-footer">' +
                '<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>' +
                '</div>' +
//          '</div>' +
            '</div>';
            
            this.moreHtml=
                '<div class="row">' +
                '<div class="col-sm-4">' +
                '<select class="form-control" id="prediction-station">' +
                '<option value="" > 请选择发布单位</option>' +
                '</select>' +
                '</div>' +
                '<div class="col-sm-4">' +
                '<select class="form-control" id="prediction-type" title="灾害类型">' +
                '<option value="" > 请选择灾害类型</option>' +
                '</select>' +
                '</div>' +
                '<div class="col-sm-4">' +
                '<select class="form-control" id="prediction-level" title="灾害等级">' +
                '<option value="" > 请选择灾害等级</option>' +
                '</select>' +
                '</div>' +
                '</div>' +
                '<div class="row">' +
                '<div class="col-sm-4">' +
                '<select class="form-control" id="prediction-status" title="灾害状态">' +
                '<option value=""> 请选择灾害状态</option>' +
                '</select>' +
                '</div>' +
                '<div class="col-sm-4">' +
                '<input type="text" class="layui-input" id="times" placeholder="请选择查询时间段"/>' +
                '</div>' +
                '<div class="col-sm-1 col-sm-offset-2">' +
                '<button class="btn btn-info" id="prediction-search" type="button">查询</button>' +
                '</div>' +
                '</div>' +
                '<div class="row">' +
                '<div class="table-responsive" id="prediction-moreDetails"></div>' +
                '</div>';
            this.$map= null;
            this.isShown=false;
            this.signalTableId="prediction-signalTable";
            this.warningTableId="prediction-warningTable";
            this.currentTab= "prediction-signal";
            this.loaded=false;
            this.map=null;
            this.urlList={
                getLatestEws: "http://61.157.118.158:8088/sndm/api/ThreeLevelMspAction/getEwsNewestSub",
                getEws: "http://61.157.118.158:8088/sndm/api/ThreeLevelMspAction/getEwsOrDwNewest?type=0",
                getDws: "http://61.157.118.158:8088/sndm/api/ThreeLevelMspAction/getEwsOrDwNewest?type=1",
                getMoreEws: "http://61.157.118.158:8088/sndm/api/ThreeLevelMspAction/getEwsOrDwAll?type=0",
                getMoreDws: "http://61.157.118.158:8088/sndm/api/ThreeLevelMspAction/getEwsOrDwAll?type=1"
            };
            this.station=[
                {
                    "U_ID": "bccd.bfsn.qxt",
                    "NAME": "遂宁市气象台",
                    "X": 105.54923917122281,
                    "Y": 30.53769573537072
                },
                {
                    "U_ID": "bccd.bfsn.nq",
                    "NAME": "遂宁市农气中心",
                    "X": 105.57573673719526,
                    "Y": 30.507530000094366
                },
                {
                    "U_ID": "bccd.bfsn.srv",
                    "NAME": "遂宁市科技服务中心",
                    "X": 105.56431760880324,
                    "Y": 30.527894615267005
                },
                {
                    "U_ID": "bccd.bfsn.ryb",
                    "NAME": "遂宁市人影办",
                    "X": 105.54921316738182,
                    "Y": 30.53782194624301
                },
                {
                    "U_ID": "bccd.bfsn.fl",
                    "NAME": "遂宁市防雷中心",
                    "X": 105.5491641862383,
                    "Y": 30.538087341375135
                },
                {
                    "U_ID": "bccd.bfsn.bxsh",
                    "NAME": "射洪县气象局",
                    "X": 105.37698776974588,
                    "Y": 30.87296073126909
                },
                {
                    "U_ID": "bccd.bfsn.bxpe",
                    "NAME": "蓬溪县气象局",
                    "X": 105.7047885130283,
                    "Y": 30.773016391470684
                },
                {
                    "U_ID": "bccd.bfsn.bxda",
                    "NAME": "大英县气象局",
                    "X": 105.24306324203664,
                    "Y": 30.583066521777
                }
            ];
            this.signalClass= {
                type: [
                    {
                        "NAME": "暴雨",
                        "P_ID": "WARN_BY"
                    },
                    {
                        "NAME": "大风",
                        "P_ID": "WARN_DF"
                    },
                    {
                        "NAME": "雷电",
                        "P_ID": "WARN_LD"
                    },
                    {
                        "NAME": "高温",
                        "P_ID": "WARN_GW"
                    },
                    {
                        "NAME": "干旱",
                        "P_ID": "WARN_GH"
                    },
                    {
                        "NAME": "大雾",
                        "P_ID": "WARN_DW"
                    },
                    {
                        "NAME": "寒潮",
                        "P_ID": "WARN_HC"
                    },
                    {
                        "NAME": "冰雹",
                        "P_ID": "WARN_BB"
                    },
                    {
                        "NAME": "暴雪",
                        "P_ID": "WARN_BX"
                    },
                    {
                        "NAME": "霜冻",
                        "P_ID": "WARN_SD"
                    },
                    {
                        "NAME": "沙尘暴",
                        "P_ID": "WARN_SB"
                    },
                    {
                        "NAME": "霾",
                        "P_ID": "WARN_MA"
                    },
                    {
                        "NAME": "道路结冰",
                        "P_ID": "WARN_DB"
                    },
                    {
                        "NAME": "森林/草原火险",
                        "P_ID": "WARN_HX"
                    }
                ],
                level: [
                    {
                        "NAME": "红色",
                        "P_ID": "WARN_%_RD",
                        "Reg": "/WARN_(\\S*?)_RD/",
                        "Regx": /WARN_(\S*?)_RD/
                    },
                    {
                        "NAME": "橙色",
                        "P_ID": "WARN_%_OR",
                        "Reg": "/WARN_(\\S*?)_OR/",
                        "Regx": /WARN_(\S*?)_OR/
                    },
                    {
                        "NAME": "黄色",
                        "P_ID": "WARN_%_YE",
                        "Reg": "/WARN_(\\S*?)_YE/",
                        "Regx": /WARN_(\S*?)_YE/
                    },
                    {
                        "NAME": "蓝色",
                        "P_ID": "WARN_%_BL",
                        "Reg": "/WARN_(\\S*?)_BL/",
                        "Regx": /WARN_(\S*?)_BL/
                    }
                ],
                status: [
                    {
                        "NAME": "发布",
                        "P_ID": "WARN_%_FB"
                    },
                    {
                        "NAME": "更新",
                        "P_ID": "WARN_%_GX"
                    },
                    {
                        "NAME": "确认",
                        "P_ID": "WARN_%_QR"
                    },
                    {
                        "NAME": "解除",
                        "P_ID": "WARN_%_JC"
                    }
                ]
            };
            this.warningClass={
                type: [
                    {
                        "NAME": "干旱",
                        "P_ID": "ALRM_GH"
                    },
                    {
                        "NAME": "暴雨",
                        "P_ID": "ALRM_BY"
                    },
                    {
                        "NAME": "大风",
                        "P_ID": "ALRM_DF"
                    },
                    {
                        "NAME": "高温",
                        "P_ID": "ALRM_GW"
                    },
                    {
                        "NAME": "低温",
                        "P_ID": "ALRM_DW"
                    },
                    {
                        "NAME": "大雾",
                        "P_ID": "ALRM_DW"
                    },
                    {
                        "NAME": "寒潮",
                        "P_ID": "ALRM_HC"
                    },
                    {
                        "NAME": "暴雪",
                        "P_ID": "ALRM_BX"
                    },
                    {
                        "NAME": "霜冻",
                        "P_ID": "ALRM_SD"
                    },
                    {
                        "NAME": "冰冻",
                        "P_ID": "ALRM_BD"
                    },
                    {
                        "NAME": "霾",
                        "P_ID": "ALRM_MA"
                    }
                ],
                level: [
                    {
                        "NAME": "红色",
                        "P_ID": "ALRM_%_RD",
                        "Reg": "/ALRM_(\\S*?)_RD/",
                        "Regx": /ALRM_(\S*?)_RD/
                    },
                    {
                        "NAME": "橙色",
                        "P_ID": "ALRM_%_OR",
                        "Reg": "/ALRM_(\\S*?)_OR/",
                        "Regx": /ALRM_(\S*?)_OR/
                    },
                    {
                        "NAME": "黄色",
                        "P_ID": "ALRM_%_YE",
                        "Reg": "/ALRM_(\\S*?)_YE/",
                        "Regx": /ALRM_(\S*?)_YE/
                    },
                    {
                        "NAME": "蓝色",
                        "P_ID": "ALRM_%_BL",
                        "Reg": "/ALRM_(\\S*?)_BL/",
                        "Regx": /ALRM_(\S*?)_BL/
                    }
                ],
                status: [
                    {
                        "NAME": "发布",
                        "P_ID": "ALRM_%_FB"
                    },
                    {
                        "NAME": "更新",
                        "P_ID": "ALRM_%_GX"
                    },
                    {
                        "NAME": "确认",
                        "P_ID": "ALRM_%_QR"
                    },
                    {
                        "NAME": "解除",
                        "P_ID": "ALRM_%_JC"
                    }
                ]
            };
            this.startDate='';
            this.endDate='';
		},

		show:function(mapDOM,containerDom,map){
			layui.config({
                dir: '../js/dep/layui/' //layui.js 所在路径（注意，如果是script单独引入layui.js，无需设定该参数。），一般情况下可以无视
         	});
            
            this.$map = $("#" + mapDOM);
            this.map = map;
//          this.$map.append(this.html);
            $(containerDom).append(this.html);
            var curInstance=this;
            $("#prediction-Show").on("click", function () {
                curInstance.isShown = !curInstance.isShown;
                if (curInstance.isShown) {
                    $(".prediction").slideDown();
                } else {
                    $(".prediction").slideUp();
                }
            });
            //切换tab
            $("#prediction-Tab li").on("click", function (event) {
                curInstance.currentTab = event.target.hash.replace("#", "");
                if (event.target.hash === "#prediction-signal") {
                    curInstance.createSignalTable(curInstance.urlList.getLatestEws,curInstance);
                } else{
                    curInstance.createWarningTable(curInstance.urlList.getDws,curInstance);
                }
            });
            
            $("#prediction-more").click(function () {
              layui.use(['layer', 'laydate'], function () {
                      var layer = layui.layer,
                          laydate = layui.laydate;
                layer.open({
                    id:'prediction-history',
                    title: '更多',
                    content: curInstance.moreHtml,
                    area: '800px',
                    offset: '2px',
                    zIndex: 999
                });
                laydate.render({
                    elem: '#times',
                    type: 'datetime',
                    range: true,
                    done: function (value, date, endDate) {
                        curInstance.startDate = date.year.toString() +
                            date.month.toString().padLeft(2, "0") +
                            date.date.toString().padLeft(2, "0") +
                            date.hours.toString().padLeft(2, "0") +
                            date.minutes.toString().padLeft(2, "0") +
                            date.seconds.toString().padLeft(2, "0");
                        curInstance.endDate = endDate.year.toString() +
                            endDate.month.toString().padLeft(2, "0") +
                            endDate.date.toString().padLeft(2, "0") +
                            endDate.hours.toString().padLeft(2, "0") +
                            endDate.minutes.toString().padLeft(2, "0") +
                            endDate.seconds.toString().padLeft(2, "0");
                    },
                });
                if (curInstance.currentTab == "prediction-signal") {
                    curInstance.createSignalMore(curInstance.urlList.getMoreEws, curInstance, {
                        tableId: "prediction-moreDetails"
                    });
                } else {
                    curInstance.createWarningMore(curInstance.urlList.getDws, curInstance, {
                        tableId: "prediction-moreDetails"
                    });
                }
                //});
            	});
              });

            //定时请求预警预报数据
            setTimeout(function () {
                curInstance.createWarningTable(curInstance.urlList.getDws, curInstance);
                curInstance.createSignalTable(curInstance.urlList.getLatestEws, curInstance);
            }, 200);
            setInterval(function () {
                curInstance.createWarningTable(curInstance.urlList.getDws, curInstance);
                curInstance.createSignalTable(curInstance.urlList.getLatestEws, curInstance);
            }, 300000);
			//this.addBorder(curInstance);
			padLeft();
		},
		
		createSignalMore: function (url, predictObj,options) {
                //绑定下拉列表
                for (var i = 0; i < predictObj.station.length; i++) {
                    var option = "<option id='" + predictObj.station[i].NAME + "'>" + predictObj.station[i].NAME + "</option>";
                    $("#prediction-station").append(option);
                }
                $.each(predictObj.signalClass, function (key, value) {
                    for (var i in value) {
                        var option = "<option id='" + value[i].NAME + "'>" + value[i].NAME + "</option>";
                        $("#prediction-" + key).append(option);
                    }
                });
                options = options || {};
                var $tableId = options.tableId || predictObj.warningTableId;
                $.ajax({
                    url: url,
                    type: 'GET',
                    success: function (data) {
                        //options = options || {};
                        //var $tableId = options.tableId || prediction.warningTableId;
                        var productClass = predictObj.signalClass;

                        var tableData = data;//warningData;
                        //2.加载产品列表
                        var $table = $("#" + $tableId);
                        var child = $table.children();
                        if (child.length > 0) {
                            child.remove();
                        }
                        $table.bootstrapTable({
                            data: tableData,
                            striped: true,                       //是否显示行间隔色
                            pagination: true,                    //是否显示分页（*）   
                            //search: true,                        //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                            pageSize: 4,                         //每页的记录行数（*）
                            //pageList: [5, 25, 50, 100],        //可供选择的每页的行数（*）
                            sidePagination: "client",
                            //showColumns: true,                 //是否显示所有的列
                            //showRefresh: true,                 //是否显示刷新按钮
                            //showToggle: true,                  //是否显示详细视图和列表视图的切换按钮
                            //cardView: false,                   //是否显示详细视图
                            //detailView: false,                 //是否显示父子表                                
                            locale: "zh-CN",                     //默认英文，设置如下就是显示中文                                
                            columns: [{
                                field: 'DESCRIPTION',
                                title: '产品标题',
                                sortable: true,
                                width: '60%',
                            },
                            {
                                field: 'P_TIME',
                                title: '发布时间',
                                sortable: true,
                                width: '30%',
                            },
                            {
                                field: 'P_USER',
                                title: '发布单位',
                                sortable: true,
                                width: '30%',
                            },
                            {
                                field: 'FILE_DOC',
                                visible: false
                            },
                            {
                                field: 'FILE_PDF',
                                visible: false
                            }],
                            rowStyle: function (row, index) {
                                //这里有5个取值代表5中颜色['active', 'success', 'info', 'warning', 'danger'];
                                var strclass = "active";
                                return { classes: strclass }
                            },
                            //uniqueId: "usrId",
                            clickToSelect: true,                 //是否启用点击选中行
                            maintainSelected: true,           //设置为 true 在点击分页按钮或搜索按钮时，将记住checkbox的选择项
                            //responseHandler: responseHandler, //在渲染页面数据之前执行的方法，此配置很重要!!!!!!!  
                        });
                        //绑定选中事件、取消事件、全部选中、全部取消  
                        $table.on('click-row.bs.table', function (e, rows) {
                            //layui_layer.open({
                            //    type: 1,
                            //    id: 'prediction-preview', //设定一个id，防止重复弹出
                            //    title: false, //不显示标题栏
                            //    closeBtn: true,
                            //    area: ['50%','2000px;'],
                            //    shade: 0.8,
                            //    offset: '2px',
                            //    //scrollbar: true,
                            //    fix: true,
                            //    content: predictObj.previewHtml,
                            //    success: function () {
                            //        predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
                            //    }                                
                            //});
                            $('#myModal').on('show.bs.modal', function () {//61.157.118.158:8088
                                predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
                            });
                            $('#myModal').modal('show');
                        });
                    },
                    error: function () { }
                });
                $("#prediction-search").on("click", function () {
                    var dic = $("#prediction-station")[0].selectedIndex === 0 ? "&dic=" : "&dic=" + $("#prediction-station")[0].options[$("#prediction-station")[0].selectedIndex].innerHTML;
                    var byDisasterType = $("#prediction-type")[0].selectedIndex === 0 ? "&byDisasterType=" : "&byDisasterType=" + $("#prediction-type")[0].options[$("#prediction-type")[0].selectedIndex].innerHTML;
                    var ByLevle = $("#prediction-level")[0].selectedIndex === 0 ? "&ByLevle=" : "&ByLevle=" + $("#prediction-level")[0].options[$("#prediction-level")[0].selectedIndex].innerHTML;
                    var ByState = $("#prediction-status")[0].selectedIndex === 0 ? "&ByState=" : "&ByState=" + $("#prediction-status")[0].options[$("#prediction-status")[0].selectedIndex].innerHTML;
                    var times = predictObj.startDate===''?"&times=":"&times=" + predictObj.startDate + "," + predictObj.endDate;//$("#prediction-status").options[$("#prediction-station").selectedIndex];
                    var newUrl = url + dic + byDisasterType + ByLevle + ByState + times;
                    $.ajax({
                        url: newUrl,
                        type: 'GET',
                        success: function (data) {
                            $("#" + $tableId).bootstrapTable('load', data);
                            predictObj.startDate = '';
                            predictObj.endDate = '';
                        }, error: function () { }
                    });

                });
            },

        createWarningMore: function (url, predictObj,options) {
            //绑定下拉列表
            for (var i = 0; i < predictObj.station.length; i++) {
                var option = "<option id='" + predictObj.station[i].NAME + "'>" + predictObj.station[i].NAME + "</option>";
                $("#prediction-station").append(option);
            }
            $.each(predictObj.warningClass, function (key, value) {
                for (var i in value) {
                    var option = "<option id='" + value[i].NAME + "'>" + value[i].NAME + "</option>";
                    $("#prediction-" + key).append(option);
                }
            });
            options = options || {};
            var $tableId = options.tableId || predictObj.warningTableId;
            $.ajax({
                url: url,
                type: 'GET',
                success: function (data) {
                    //options = options || {};
                    //var $tableId = options.tableId || predictObj.warningTableId;
                    var productClass = predictObj.warningClass;

                    var tableData = data;//warningData;
                    //2.加载产品列表
                    var $table = $("#" + $tableId);
                    var child = $table.children();
                    if (child.length > 0) {
                        child.remove();
                    }
                    $table.bootstrapTable({
                        data: tableData,
                        striped: true,                       //是否显示行间隔色
                        pagination: true,                    //是否显示分页（*）                                
                        //search: true,                        //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大                                                           
                        pageSize: 4,                         //每页的记录行数（*）
                        //pageList: [5, 25, 50, 100],        //可供选择的每页的行数（*）
                        sidePagination: "client",
                        //showColumns: true,                 //是否显示所有的列
                        //showRefresh: true,                 //是否显示刷新按钮
                        //showToggle: true,                  //是否显示详细视图和列表视图的切换按钮
                        //cardView: false,                   //是否显示详细视图
                        //detailView: false,                 //是否显示父子表                                
                        locale: "zh-CN",                     //默认英文，设置如下就是显示中文                                
                        columns: [{
                            field: 'DESCRIPTION',
                            title: '产品标题',
                            sortable: true,
                            width: '60%',
                        },
                        {
                            field: 'P_TIME',
                            title: '发布时间',
                            sortable: true,
                            width: '30%',
                        },
                        {
                            field: 'P_USER',
                            title: '发布单位',
                            sortable: true,
                            width: '30%',
                        },
                        {
                            field: 'FILE_DOC',
                            visible: false
                        },
                        {
                            field: 'FILE_PDF',
                            visible: false
                        }],
                        rowStyle: function (row, index) {
                            //这里有5个取值代表5中颜色['active', 'success', 'info', 'warning', 'danger'];
                            var strclass = "active";
                            return { classes: strclass }
                        },
                        //uniqueId: "usrId",
                        clickToSelect: true,                 //是否启用点击选中行
                        maintainSelected: true,           //设置为 true 在点击分页按钮或搜索按钮时，将记住checkbox的选择项
                        //responseHandler: responseHandler, //在渲染页面数据之前执行的方法，此配置很重要!!!!!!!  
                    });
                    //绑定选中事件、取消事件、全部选中、全部取消  
                    $table.on('click-row.bs.table', function (e, rows) {                            
                        $('#myModal').on('show.bs.modal', function () {//61.157.118.158:8088
                            predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
                        });
                        $('#myModal').modal('show');
                    });
                },
                error: function () { }
            });
            $("#prediction-search").on("click", function () {
                var dic = $("#prediction-station")[0].selectedIndex === 0 ? "&dic=" : "&dic=" + $("#prediction-station")[0].options[$("#prediction-station")[0].selectedIndex].innerHTML;
                var byDisasterType = $("#prediction-type")[0].selectedIndex === 0 ? "&byDisasterType=" : "&byDisasterType=" + $("#prediction-type")[0].options[$("#prediction-type")[0].selectedIndex].innerHTML;
                var ByLevle = $("#prediction-level")[0].selectedIndex === 0 ? "&ByLevle=" : "&ByLevle=" + $("#prediction-level")[0].options[$("#prediction-level")[0].selectedIndex].innerHTML;
                var ByState = $("#prediction-status")[0].selectedIndex === 0 ? "&ByState=" : "&ByState=" + $("#prediction-status")[0].options[$("#prediction-status")[0].selectedIndex].innerHTML;
                var times = predictObj.startDate === '' ? "&times=" : "&times=" + predictObj.startDate + "," + predictObj.endDate;//$("#prediction-status").options[$("#prediction-station").selectedIndex];
                var newUrl = url + dic + byDisasterType + ByLevle + ByState + times;
                $.ajax({
                    url: newUrl,
                    type: 'GET',
                    success: function (data) {
                        $("#" + $tableId).bootstrapTable('load', data);
                        predictObj.startDate = '';
                        predictObj.endDate = '';
                    }, error: function () { }
                });
            });
        },

    
        //获取最新预警信号列表并初始化表格
        createSignalTable: function (url, predictObj, options) {
            $.ajax({
                url: url,
                type: 'GET',
                success: function (data) {
                    options = options || {};
                    var $tableId = options.tableId || predictObj.signalTableId;
                    var isShowLayer = options.showLayer || true;
                    var layerNameSuffix = "_信号";
                    var productClass = predictObj.signalClass;
                    var tableData = [];
                    data = [{
                        ISSUE: "2018年第0006期",
                        DESCRIPTION: "大英县发布雷电黄色预警信号",
                        FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_LD_YE_FB_BXDA_20180316211500_20180006.docx&fileType=ews_file_doc&fileTime=20180316",
                        P_NAME: "雷电黄色预警信号发布单",
                        P_TIME: "2018-03-16 21:15:00",
                        P_USER: "大英县气象局",
                        FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_LD_YE_FB_BXDA_20180316211500_20180006.pdf&fileType=ews_file_pdf&fileTime=20180316"
                    },
                        {
                            ISSUE: "2018年第0007期",
                            DESCRIPTION: "射洪县发布大风蓝色预警信号",
                            FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXSH_20180304130900_20180007.docx&fileType=ews_file_doc&fileTime=20180304",
                            P_NAME: "大风蓝色预警信号发布单",
                            P_TIME: "2018-03-04 13:09:00",
                            P_USER: "射洪县气象局",
                            FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXSH_20180304130900_20180007.pdf&fileType=ews_file_pdf&fileTime=20180304"
                        },
                        {
                            ISSUE: "2018年第0005期",
                            DESCRIPTION: "大英县发布大风蓝色预警信号",
                            FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXDA_20180304125900_20180005.docx&fileType=ews_file_doc&fileTime=20180304",
                            P_NAME: "大风蓝色预警信号发布单",
                            P_TIME: "2018-03-04 12:59:00",
                            P_USER: "大英县气象局",
                            FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXDA_20180304125900_20180005.pdf&fileType=ews_file_pdf&fileTime=20180304"           
                        },
                        {
                            ISSUE: "2018年第0007期",
                            DESCRIPTION: "蓬溪县发布大风蓝色预警信号",
                            FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXPE_20180304121200_20180007.docx&fileType=ews_file_doc&fileTime=20180304",
                            P_NAME: "大风蓝色预警信号发布单",
                            P_TIME: "2018-03-04 12:12:00",
                            P_USER: "蓬溪县气象局",
                            FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXPE_20180304121200_20180007.pdf&fileType=ews_file_pdf&fileTime=20180304"
                        },
                        {
                            ISSUE: "2018年第0007期",
                            DESCRIPTION: "遂宁市发布大风蓝色预警信号",
                            FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BFSN_20180304114500_20180007.docx&fileType=ews_file_doc&fileTime=20180304",
                            P_NAME: "大风蓝色预警信号发布单",
                            P_TIME: "2018-03-04 11:45:00",
                            P_USER: "遂宁市气象台",
                            FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BFSN_20180304114500_20180007.pdf&fileType=ews_file_pdf&fileTime=20180304"
                        },
                        {
                            ISSUE: "2018年第0006期",
                            DESCRIPTION: "射洪县发布大雾黄色预警信号",
                            FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXSH_20180216075500_20180006.docx&fileType=ews_file_doc&fileTime=20180216",
                            P_NAME: "大雾黄色预警信号发布单",
                            P_TIME: "2018-02-16 07:55:00",
                            P_USER: "射洪县气象局",
                            FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXSH_20180216075500_20180006.pdf&fileType=ews_file_pdf&fileTime=20180216"
                        },
                        {
                            ISSUE: "2018年第0006期",
                            DESCRIPTION: "遂宁市发布大雾黄色预警信号",
                            FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BFSN_20180216074500_20180006.docx&fileType=ews_file_doc&fileTime=20180216",
                            P_NAME: "大雾黄色预警信号发布单",
                            P_TIME: "2018-02-16 07:45:00",
                            P_USER: "遂宁市气象台",
                            FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BFSN_20180216074500_20180006.pdf&fileType=ews_file_pdf&fileTime=20180216"
                        },
                        {
                            ISSUE: "2018年第0006期",
                            DESCRIPTION: "蓬溪县发布大雾黄色预警信号",
                            FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXPE_20180216074100_20180006.docx&fileType=ews_file_doc&fileTime=20180216",
                            P_NAME: "大雾黄色预警信号发布单",
                            P_TIME: "2018-02-16 07:41:00",
                            P_USER: "蓬溪县气象局",
                            FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXPE_20180216074100_20180006.pdf&fileType=ews_file_pdf&fileTime=20180216"
                        }];
                    if (data.length > 0 && isShowLayer) {
                        tableData = [];
                        var layerList = {}, sameCoordsList = {};
                        for (var i=0;i<data.length;i++) {
                            var description = data[i]["DESCRIPTION"];
                            var sameCoords = data[i]["P_USER"];
                            for (var j=0;j<productClass.type.length;j++) {
                                if (description.match(productClass.type[j]["NAME"])) {
                                    layerList[productClass.type[j]["NAME"]] = layerList[productClass.type[j]["NAME"]] || [];
                                    layerList[productClass.type[j]["NAME"]].push(data[i]);
                                }
                            }
                            sameCoordsList[data[i]["P_USER"]] = sameCoordsList[data[i]["P_USER"]] || [];
                            sameCoordsList[data[i]["P_USER"]].push(data[i]["P_USER"]);
                        }
                        //表格与地图图层关联----加载图层

                        for (var i in layerList) {
                            var layerJSON = predictObj.createLayerJSON(layerList[i], sameCoordsList, tableData, predictObj);
                            var pFeaLayer = predictObj.createFeatureLayer(layerJSON, ["gid"], "gid", {
                                layerInfo: {
                                    LayerId: i + layerNameSuffix,
                                    LayerName: i + layerNameSuffix,
                                    Labeled: false,
                                    Lods: [],
                                    Transparency: 1
                                },
                                geometryType: "esriGeometryPoint",
                                levelClass: productClass.level,
                                typeClass: productClass.type
                            }, predictObj);
                            pFeaLayer.on("mouse-over", function (evt) {
                                var g = evt.graphic;
                                predictObj.map.infoWindow.setContent(g.getContent());
                                predictObj.map.infoWindow.setTitle(g.getTitle());
                                //predictObj.map.infoWindow.show(evt.screenPoint, predictObj.map.getInfoWindowAnchor(evt.screenPoint));
                            	predictObj.map.infoWindow.show(g.geometry,predictObj.map.getInfoWindowAnchor(g.geometry));
                            });
                            pFeaLayer.on("mouse-out", function (evt) {
                                predictObj.map.infoWindow.hide();
                            });
                            pFeaLayer.on("click", function (evt) {
                                var g = evt.graphic;
                                $('#myModal').on('show.bs.modal', function () {//61.157.118.158:8088
                                    predictObj.showPdf($('#preview-msg')[0], g.attributes.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
                                });
                                $('#myModal').modal('show');
                            });
                            predictObj.map.addLayer(pFeaLayer);
                        }
                    } else if (data.length > 0 && !isShowLayer) {
                        tableData = data;
                    }

                    //2.加载预警信号列表
                    var $table = $("#" + $tableId);
                    var child = $table.children();
                    if (child.length > 0) {
                        child.remove();
                    }
                    $table.bootstrapTable({
                        data: tableData,
                        height:'500px',
                        striped: true,                       //是否显示行间隔色
                        pagination: true,                    //是否显示分页（*）                                
                        search: true,                        //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大                                                                                  
                        pageSize: 5,                         //每页的记录行数（*）
                        //pageList: [5, 25, 50, 100],        //可供选择的每页的行数（*）
                        sidePagination: "client",
                        //showColumns: true,                 //是否显示所有的列
                        //showRefresh: true,                 //是否显示刷新按钮
                        //showToggle: true,                  //是否显示详细视图和列表视图的切换按钮
                        //cardView: false,                   //是否显示详细视图
                        //detailView: false,                 //是否显示父子表                                
                        locale: "zh-CN",                     //默认英文，设置如下就是显示中文                                
                        columns: [{
                            field: 'DESCRIPTION',
                            title: '产品标题',
                            sortable: true,
                        }, {
                            field: 'P_TIME',
                            title: '发布时间',
                            sortable: true,
                        },
                        {
                            field: 'P_USER',
                            title: '发布单位',
                            sortable: true,
                        },
                        {
                            field: 'FILE_DOC',
                            visible: false
                        },
                        {
                            field: 'FILE_PDF',
                            visible: false
                        },
                        {
                            field: 'X',
                            visible: false
                        },
                        {
                            field: 'Y',
                            visible: false
                        }],
                        rowStyle: function (row, index) {
                            //这里有5个取值代表5中颜色['active', 'success', 'info', 'warning', 'danger'];
                            var strclass = "active";
                            return { classes: strclass }
                        },
                        //uniqueId: "usrId",
                        clickToSelect: true,                 //是否启用点击选中行
                        maintainSelected: true,           //设置为 true 在点击分页按钮或搜索按钮时，将记住checkbox的选择项
                        //responseHandler: responseHandler, //在渲染页面数据之前执行的方法，此配置很重要!!!!!!!  
                    });
                    //绑定选中事件、取消事件、全部选中、全部取消  
                    $table.on('click-row.bs.table', function (e, rows) {
                        predictObj.map.centerAndZoom(new esri.geometry.Point(rows.X, rows.Y, 4326), 13);  
                        $('#myModal').on('show.bs.modal', function () {//61.157.118.158:8088
                            predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
                        });
                        $('#myModal').modal('show');
                    });
                },
                error: function () { }
            });
        },

        //获取灾害预警列表并初始化表格
        createWarningTable: function (url, predictObj, options) {
            $.ajax({
                url: url,
                type: 'GET',
                success: function (data) {
                    options = options || {};
                    var $tableId = options.tableId || predictObj.warningTableId;
                    var productClass = predictObj.warningClass;

                    var tableData = data;//warningData;
                    //2.加载产品列表
                    var $table = $("#" + $tableId);
                    var child = $table.children();
                    if (child.length > 0) {
                        child.remove();
                    }
                    $table.bootstrapTable({
                        data: tableData,
                        height:'500px',
                        striped: true,                       //是否显示行间隔色
                        pagination: true,                    //是否显示分页（*）                                
                        search: true,                        //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大        
                        pageSize: 5,                         //每页的记录行数（*）
                        //pageList: [5, 25, 50, 100],        //可供选择的每页的行数（*）
                        sidePagination: "client",
                        //showColumns: true,                 //是否显示所有的列
                        //showRefresh: true,                 //是否显示刷新按钮
                        //showToggle: true,                  //是否显示详细视图和列表视图的切换按钮
                        //cardView: false,                   //是否显示详细视图
                        //detailView: false,                 //是否显示父子表                                
                        locale: "zh-CN",                     //默认英文，设置如下就是显示中文                                
                        columns: [{
                            field: 'DESCRIPTION',
                            title: '产品标题',
                            sortable: true,
                        }, {
                            field: 'P_TIME',
                            title: '发布时间',
                            sortable: true,
                        },
                        {
                            field: 'P_USER',
                            title: '发布单位',
                            sortable: true,
                        },
                        {
                            field: 'FILE_DOC',
                            visible: false
                        },
                        {
                            field: 'FILE_PDF',
                            visible: false
                        }],
                        rowStyle: function (row, index) {
                            //这里有5个取值代表5中颜色['active', 'success', 'info', 'warning', 'danger'];
                            var strclass = "active";
                            return { classes: strclass }
                        },
                        //uniqueId: "usrId",
                        clickToSelect: true,                 //是否启用点击选中行
                        maintainSelected: true,           //设置为 true 在点击分页按钮或搜索按钮时，将记住checkbox的选择项
                        //responseHandler: responseHandler, //在渲染页面数据之前执行的方法，此配置很重要!!!!!!!  
                    });
                    //绑定选中事件、取消事件、全部选中、全部取消  
                    $table.on('click-row.bs.table', function (e, rows) { 
                        $('#myModal').on('show.bs.modal', function () {//61.157.118.158:8088
                            predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
                        });
                        $('#myModal').modal('show');
                    });
                },
                error: function () { }
            });
        },

        //构造GeoJSON
        createLayerJSON: function (records, sameCoordsList, tableData, predictObj) {
            var geojson = {},
                features = [],
                feature, geometry, points;
            geojson.type = "FeatureCollection";
            geojson.features = features;

            for (var i = 0; i < records.length; i++) {
                feature = {};
                feature.type = 'Feature';
                geometry = feature.geometry = {};
                geometry.type = "Point";
                var coords = [];
                var station = predictObj.station;
                for (var j = 0; j < station.length; j++) {
                    if (records[i]["P_USER"] === station[j].NAME) {
                        var sameCrdCount = sameCoordsList[records[i]["P_USER"]].length;
                        var xMin = station[j].X - 0.00001042 * 3000 * sameCrdCount / 2;//0.00001042表示东西方向一米的距离
                        var xMax = station[j].X + 0.00001042 * 3000 * sameCrdCount / 2;
                        var yMin = station[j].Y - 0.00000899 * 3000 * sameCrdCount / 2;//0.00000899表示南北方向一米的距离
                        var yMax = station[j].Y + 0.00000899 * 3000 * sameCrdCount / 2;
                        coords.push(parseFloat((xMax - xMin) * Math.random() + xMin));
                        coords.push(parseFloat((yMax - yMin) * Math.random() + yMin));
                    }
                }

                geometry.coordinates = coords;
                if ("coordinates" in feature.geometry) features.push(feature);
                var displayRecords = records[i];
                displayRecords["gid"] = displayRecords["gid"] || i;
                displayRecords["X"] = displayRecords["X"] || coords[0];
                displayRecords["Y"] = displayRecords["Y"] || coords[1];
                properties = feature.properties = displayRecords;
                tableData.push(displayRecords);
            };
            return geojson;
        },

        createFeatureLayer: function (layerJson, fieldList, oid, options, predictObj) {
            //id, name, geometryType, 
            var id = options.layerInfo.LayerId, name = options.layerInfo.LayerName, geometryType = options.geometryType,
                layerInfo = options.layerInfo, hasZM = false, levelClass = options.levelClass, typeClass = options.typeClass;
            var symbol;
            //1.定义展示字段
            var fields = [], field;
            for (var i = 0; i < fieldList.length; i++) {
                if (fieldList[i] === oid) {
                    field = {
                        "name": oid,
                        "alias": oid,
                        "type": "esriFieldTypeOID",
                        "length": "50",
                        "nullable": "false",
                        "editable": "false"
                    }
                } else {
                    field = {
                        "name": fieldList[i],
                        "alias": fieldList[i],
                        "type": "esriFieldTypeString",
                        "length": "80",
                        "nullable": "true",
                        "editable": "false"
                    }
                }
                fields.push(field);
            }
            //2.定义空图层基本信息            
            var layerDefinition = {
                "geometryType": geometryType,
                "objectIdField": oid,
                "fields": fields,
                "drawingInfo": {
                    "renderer": {
                        "type": "simple",
                        "symbol": symbol
                    }
                }
            }
            var featureCollection = {
                layerDefinition: layerDefinition,
                featureSet: null
            };
            var popupTemplate = new esri.dijit.PopupTemplate({
                title: "{DESCRIPTION}",
                description: "发布单位：{P_USER}</br>发布时间：{P_TIME}</br>发布期号：{ISSUE}</br>"
            });
            var featureLayer = new esri.layers.FeatureLayer(featureCollection, {
                id: id,
                outFields: fieldList,
                infoTemplate: popupTemplate,
                showLabels: true
            });

            //3.添加要素
            if (layerJson.features.length <= 0) {
                return;
            }
            var features = [], isClassified = true, symbol;
            for (var j = 0; j < layerJson.features.length; j++) {
                var geometry, value = null, feature = layerJson.features[j];
                geometry = predictObj.geojson2graphic(feature.geometry);
                var description = feature.properties["DESCRIPTION"];
                var pictureName = "";
                for (var m in typeClass) {
                    if (description.match(typeClass[m]["NAME"])) {
                        pictureName += typeClass[m]["P_ID"];
                        break;
                    }
                }
                for (var n in levelClass) {
                    if (description.match(levelClass[n]["NAME"])) {
                        pictureName += levelClass[n]["P_ID"].substring(levelClass[n]["P_ID"].length - 3);
                        if (!predictObj.validateImage("../js/prediction/img/prediction/" + pictureName + ".jpg")) {
                            pictureName = "WARN_QT";
                        }
                        symbol = predictObj.Symbology.pictureMarkerSymbol({
                            Url: "../js/prediction/img/prediction/" + pictureName + ".jpg",
                            Size: 32
                        })
                        break;
                    }
                }
                var graphic = new esri.Graphic(geometry, symbol, layerJson.features[j].properties, featureLayer.infoTemplate);
                features.push(graphic);
                featureLayer.add(graphic);
            }
            featureLayer._featureSet = {
                "features": features,
                "geometryType": geometryType
            }
            featureLayer._featureLayer = features;
            featureLayer.graphics = features;
            featureLayer.opacity = layerInfo.Transparency;
            if (layerInfo.Lods.length > 0) {
                featureLayer.setScaleRange(Math.max.apply(Math, layerInfo.Lods), Math.min.apply(Math, layerInfo.Lods));
            }
            if (hasZM) {
                featureLayer.hasZ = true;
                featureLayer.hasM = true;
            }
            return featureLayer;
        },

        geojson2graphic: function (geojson, options) {
            var spatialReference;

            options = options || { sr: 4326 };
            var idAttribute = options.idAttribute || "gid" || "OBJECTID";

            if (options.sr) {
                spatialReference = { wkid: options.sr };
            }
            else {
                spatialReference = { wkid: 4326 };
            }

            var result = {};
            var i;
            switch (geojson.type) {
                case "Point":
                    result.x = geojson.coordinates[0];
                    result.y = geojson.coordinates[1];
                    if (geojson.coordinates[2]) {
                        result.z = geojson.coordinates[2];
                    }
                    if (geojson.coordinates[3]) {
                        result.m = geojson.coordinates[3];
                    }
                    result.spatialReference = spatialReference;
                    result = new esri.geometry.Point(result);
                    break;
                case "MultiPoint":
                    result.points = geojson.coordinates.slice(0);
                    result.spatialReference = spatialReference;
                    result = new esri.geometry.Multipoint(result);
                    break;
                case "LineString":
                    result.paths = [geojson.coordinates.slice(0)];
                    result.spatialReference = spatialReference;
                    result = new esri.geometry.Polyline(result);
                    break;
                case "MultiLineString":
                    try {
                        result.paths = geojson.coordinates.slice(0);
                        result.spatialReference = spatialReference;
                        result = new esri.geometry.Polyline(result);
                    } catch (e) {
                        var aaa = e;
                    }
                    break;
                case "Polygon":
                    result.rings = orientRings(geojson.coordinates.slice(0));
                    result.spatialReference = spatialReference;
                    result = new esri.geometry.Polygon(result);
                    break;
                case "MultiPolygon":
                    result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0));
                    result.spatialReference = spatialReference;
                    result = new esri.geometry.Polygon(result);
                    break;
                case "Feature":
                    if (geojson.geometry) {
                        result.geometry = predictObj.geojson2graphic(geojson.geometry, options);
                    }
                    result.attributes = (geojson.properties) ? predictObj.clone(geojson.properties) : {};
                    result.attributes[idAttribute] = geojson.id;
                    break;
                case "FeatureCollection":
                    result = [];
                    for (i = 0; i < geojson.features.length; i++) {
                        result.push(predictObj.geojson2graphic(geojson.features[i], options));
                    }
                    break;
                case "GeometryCollection":
                    result = [];
                    for (i = 0; i < geojson.geometries.length; i++) {
                        result.push(predictObj.geojson2graphic(geojson.geometries[i], options));
                    }
                    break;
            }

            return result;
        },

        clone: function (obj) {
            var target = {};
            for (var i in obj) {
                if (obj.hasOwnProperty(i)) {
                    target[i] = obj[i];
                }
            }
            return target;
        },

        //PDF文件预览
        showPdf: function (container, url) {
            container.style.display = "block";
            PDFJS.workerSrc = '../js/prediction/dep/pdf-worker.js';
            PDFJS.getDocument(url).then(function getPdfHelloWorld(pdf) {
                //
                // Fetch the first page
                //                    
                pdf.getPage(1).then(function getPageHelloWorld(page) {
                    var scale = 1.5;
                    var viewport = page.getViewport(scale);

                    //
                    // Prepare canvas using PDF page dimensions
                    //
                    var canvas = document.getElementById('the-canvas');
                    canvas.remove();
                    $("#pop").append('<canvas id="the-canvas"></canvas>');
                    canvas = document.getElementById('the-canvas');
                    var context = canvas.getContext('2d');

                    canvas.height = viewport.height;
                    canvas.width = viewport.width;

                    // Render PDF page into canvas context
                    //
                    var renderContext = {
                        canvasContext: context,
                        viewport: viewport
                    };
                    page.render(renderContext);
                });
            });
        },

        //判断图片是否存在
        validateImage: function (url) {
            var xmlHttp;
            if (window.ActiveXObject) {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            else if (window.XMLHttpRequest) {
                xmlHttp = new XMLHttpRequest();
            }
            xmlHttp.open("Get", url, false);
            xmlHttp.send();
            if (xmlHttp.status == 404)
                return false;
            else
                return true;
        },


        Symbology: {
            pointSymbol: function (options) {
                var pSymbol = new esri.symbol.SimpleMarkerSymbol();
                pSymbol.setPath(options.iconUrl);
                pSymbol.setColor(options.iconColor);
                pSymbol.setSize(options.iconSize);
                return pSymbol;
            },

            polylineSymbol: function (options) {
                var pSymbol = new esri.symbol.SimpleLineSymbol();
                var style = options.iconUrl.split(' ')[0]
                switch (style) {
                    case "STYLE_SOLID":
                        pSymbol.setStyle(esri.symbol.SimpleLineSymbol.STYLE_SOLID);
                        break;
                    case "STYLE_SHORTDOT":
                        pSymbol.setStyle(esri.symbol.SimpleLineSymbol.STYLE_SHORTDOT);
                        break;
                    case "STYLE_LONGDASH":
                        pSymbol.setStyle(esri.symbol.SimpleLineSymbol.STYLE_LONGDASH);
                        break;
                    case "STYLE_LONGDASHDOT":
                        pSymbol.setStyle(esri.symbol.SimpleLineSymbol.STYLE_LONGDASHDOT);
                        break;
                }
                pSymbol.setColor(options.iconColor);
                pSymbol.setWidth(options.iconSize);
                return pSymbol;
            },

            polygonSymbol: function (options) {
                var pSymbol = new esri.symbol.SimpleFillSymbol();
                var colors = options.iconColor.split(';');
                var style = options.iconUrl, outlineStyle;
                switch (style) {
                    case "STYLE_SOLID":
                        outlineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
                        break;
                    case "STYLE_SHORTDOT":
                        outlineStyle = esri.symbol.SimpleLineSymbol.STYLE_SHORTDOT;
                        break;
                    case "STYLE_LONGDASH":
                        pSymbol.setStyle(esri.symbol.SimpleLineSymbol.STYLE_LONGDASH);
                        break;
                    case "STYLE_LONGDASHDOT":
                        outlineStyle = esri.symbol.SimpleLineSymbol.STYLE_LONGDASHDOT;
                        break;
                    default:
                        outlineStyle = null;
                        break;
                }
                pSymbol.setStyle(esri.symbol.SimpleFillSymbol.STYLE_SOLID);
                if (outlineStyle !== null) {
                    pSymbol.setOutline(new esri.symbol.SimpleLineSymbol().setStyle(outlineStyle).setWidth(options.iconSize).setColor(new esri.Color(colors[1])));
                } else {
                    pSymbol.setOutline(new esri.symbol.SimpleLineSymbol().setWidth(0));
                }
                pSymbol.setColor(colors[0]);
                return pSymbol;
            },

            pictureMarkerSymbol: function (options) {
                var pSymbol = new esri.symbol.PictureMarkerSymbol({
                    "url": options.Url,
                    "height": options.Size,
                    "width": options.Size,
                    "type": "esriPMS",
                    "angle": 0,
                });
                return pSymbol;
            },

            rendererPoint: function (value, drawInfo, isClassified) {
                var pSymbol;
                if (isClassified) {
                    for (var i = 0; i < drawInfo.length; i++) {
                        if (value === drawInfo[i].value) {
                            if (drawInfo[i].iconUrl.indexOf("img") > -1) {
                                var url = window.location.origin + drawInfo[i].iconUrl;
                                pSymbol = predictObj.Symbology.pictureMarkerSymbol({
                                    Url: url,
                                    Size: drawInfo[i].iconSize
                                });
                            } else {
                                pSymbol = predictObj.Symbology.pointSymbol({
                                    iconColor: drawInfo[i].iconColor,
                                    iconUrl: drawInfo[i].iconUrl,
                                    iconSize: drawInfo[i].iconSize
                                });
                            }
                        }
                    }
                } else {
                    if (drawInfo[0].iconUrl.indexOf("img") > -1) {
                        url = window.location.origin + drawInfo[0].iconUrl;
                        pSymbol = predictObj.Symbology.pictureMarkerSymbol({
                            Url: url,
                            Size: drawInfo[0].iconSize
                        });
                    } else {
                        pSymbol = predictObj.Symbology.pointSymbol({
                            iconColor: drawInfo[0].iconColor,
                            iconUrl: drawInfo[0].iconUrl,
                            iconSize: drawInfo[0].iconSize
                        });
                    }
                }
                return pSymbol;
            },

            rendererLine: function (value, drawInfo, isClassified) {
                var pSymbol;
                if (isClassified) {
                    for (var i = 0; i < drawInfo.length; i++) {
                        if (value === drawInfo[i].value) {
                            pSymbol = predictObj.Symbology.polylineSymbol({
                                iconColor: drawInfo[i].iconColor,
                                iconUrl: drawInfo[i].iconUrl,
                                iconSize: drawInfo[i].iconSize
                            });
                        }
                    }
                } else {
                    pSymbol = predictObj.Symbology.polylineSymbol({
                        iconColor: drawInfo[0].iconColor,
                        iconUrl: drawInfo[0].iconUrl,
                        iconSize: drawInfo[0].iconSize
                    });
                }
                return pSymbol;
            },

            rendererPolygon: function (value, drawInfo, isClassified) {
                var pSymbol;// = new esri.symbol.SimpleFillSymbol();
                if (isClassified) {
                    for (var i = 0; i < drawInfo.length; i++) {
                        if (value === drawInfo[i].value) {
                            pSymbol = predictObj.Symbology.polygonSymbol({
                                iconColor: drawInfo[i].iconColor,
                                iconUrl: drawInfo[i].iconUrl,
                                iconSize: drawInfo[i].iconSize
                            });
                        }
                    }
                } else {
                    pSymbol = predictObj.Symbology.polygonSymbol({
                        iconColor: drawInfo[0].iconColor,
                        iconUrl: drawInfo[0].iconUrl,
                        iconSize: drawInfo[0].iconSize
                    });
                }
                return pSymbol;
            },
        },
        //加载css文件
        loadStyle: function (urlList, callback) {
            for (var i in urlList) {
                var url = urlList[i];
                var link = document.createElement('link');
                link.type = 'text/css';
                link.rel = 'stylesheet';
                link.href = url;
                var head = document.getElementsByTagName('head')[0];
                head.appendChild(link);
            }
            callback();
        },

        
        addBorder:function (obj) {
			var borderlayer = new esri.layers.GraphicsLayer();
				obj.map.addLayer(borderlayer);

				var csq = "POLYGON((105.72196 30.6448,105.73176 30.6402,105.73216 30.6186,105.73586 30.6102,105.73396 30.6005,105.71546 30.5841,105.71586 30.5669,105.70476 30.5635,105.70396 30.5536,105.70966 30.5421,105.70426 30.5048,105.68246 30.5187,105.67416 30.5111,105.66966 30.4938,105.67166 30.4847,105.65706 30.4784,105.65216 30.4685,105.65396 30.4589,105.64166 30.4487,105.64626 30.439,105.66146 30.4403,105.67356 30.4482,105.68436 30.4463,105.69246 30.4375,105.69716 30.4233,105.70606 30.4185,105.71346 30.3983,105.72476 30.4026,105.74046 30.4141,105.75216 30.418,105.75426 30.4086,105.75046 30.396,105.75656 30.3874,105.76476 30.3758,105.74986 30.3645,105.75256 30.3497,105.74616 30.3423,105.73066 30.3353,105.73756 30.3247,105.72586 30.3197,105.71866 30.3249,105.71966 30.3424,105.72566 30.35,105.70916 30.357,105.70956 30.3741,105.69506 30.3763,105.68786 30.366,105.67586 30.3623,105.66676 30.3859,105.64576 30.3861,105.63486 30.3967,105.63046 30.3912,105.61576 30.3921,105.61216 30.3834,105.60126 30.3818,105.59216 30.3891,105.56206 30.3878,105.55486 30.3945,105.55116 30.4052,105.54016 30.4101,105.53926 30.4256,105.52966 30.4396,105.53346 30.4475,105.52156 30.4565,105.51256 30.4582,105.50626 30.4747,105.50556 30.4876,105.48346 30.5052,105.49366 30.5136,105.48606 30.525,105.48426 30.5398,105.47646 30.5491,105.45326 30.5372,105.44256 30.5381,105.43806 30.548,105.42166 30.551,105.41676 30.567,105.40886 30.5704,105.39976 30.5569,105.38816 30.5649,105.40176 30.5832,105.40856 30.5873,105.40576 30.5962,105.41836 30.6035,105.42256 30.6138,105.43226 30.6198,105.44276 30.6156,105.45116 30.6331,105.47216 30.6355,105.48626 30.6403,105.48896 30.6475,105.49836 30.6529,105.50786 30.6455,105.51656 30.6516,105.52376 30.6401,105.54156 30.6398,105.55046 30.6301,105.56716 30.62,105.59896 30.6386,105.62586 30.6185,105.63486 30.622,105.64766 30.6198,105.65166 30.6271,105.66266 30.6334,105.66816 30.6246,105.67966 30.6273,105.68346 30.6371,105.70036 30.6406,105.70806 30.6585,105.72196 30.6448))";
				var ajq = "POLYGON((105.41676 30.567,105.42166 30.551,105.43806 30.548,105.44256 30.5381,105.45326 30.5372,105.47646 30.5491,105.48426 30.5398,105.48606 30.525,105.49366 30.5136,105.48346 30.5052,105.50556 30.4876,105.50626 30.4747,105.51256 30.4582,105.52156 30.4565,105.53346 30.4475,105.52966 30.4396,105.53926 30.4256,105.54016 30.4101,105.55116 30.4052,105.55486 30.3945,105.56206 30.3878,105.59216 30.3891,105.60126 30.3818,105.61216 30.3834,105.61576 30.3921,105.63046 30.3912,105.63486 30.3967,105.64576 30.3861,105.66676 30.3859,105.67586 30.3623,105.68786 30.366,105.69506 30.3763,105.70956 30.3741,105.70916 30.357,105.72566 30.35,105.71966 30.3424,105.71866 30.3249,105.70816 30.3185,105.71506 30.3104,105.70546 30.3026,105.70966 30.2904,105.72646 30.2685,105.71736 30.2658,105.72026 30.2574,105.70176 30.2597,105.66986 30.2555,105.66496 30.267,105.65716 30.2671,105.64226 30.2761,105.61926 30.2766,105.61676 30.2646,105.60726 30.2587,105.61696 30.2518,105.61676 30.237,105.63286 30.2225,105.65196 30.2236,105.65886 30.2128,105.64206 30.2097,105.63896 30.1892,105.62946 30.1866,105.61486 30.1884,105.60456 30.1811,105.59176 30.1865,105.57656 30.1763,105.56366 30.186,105.55616 30.1855,105.55806 30.1915,105.55536 30.1964,105.55906 30.1991,105.53386 30.2206,105.52656 30.2222,105.51716 30.2049,105.49366 30.2211,105.48716 30.2179,105.47756 30.2282,105.48046 30.2346,105.46976 30.2511,105.45696 30.2586,105.44266 30.2563,105.42106 30.2632,105.41266 30.2819,105.41596 30.2925,105.40346 30.2928,105.37776 30.2788,105.36716 30.2788,105.36326 30.2933,105.34876 30.3055,105.33046 30.3124,105.32426 30.3055,105.29126 30.2973,105.27916 30.2878,105.27276 30.2918,105.26066 30.2877,105.25516 30.2827,105.23376 30.285,105.22726 30.2812,105.21616 30.2922,105.21416 30.3111,105.19806 30.3076,105.19386 30.3137,105.18336 30.3145,105.17406 30.3228,105.16886 30.3188,105.15246 30.3268,105.14476 30.3409,105.11696 30.3487,105.11806 30.3558,105.10516 30.3709,105.10586 30.3823,105.09716 30.3859,105.09586 30.3943,105.08776 30.4035,105.07616 30.41,105.08666 30.4172,105.08606 30.4313,105.10876 30.435,105.11326 30.4455,105.12666 30.4474,105.14196 30.4639,105.16386 30.4729,105.16256 30.4641,105.18096 30.4718,105.19306 30.47,105.19316 30.4779,105.20286 30.4851,105.22366 30.4841,105.23936 30.474,105.23856 30.4619,105.25676 30.449,105.27656 30.4598,105.27946 30.477,105.29356 30.4736,105.30816 30.4597,105.31836 30.4625,105.31886 30.4876,105.33426 30.4953,105.35236 30.4958,105.36016 30.5036,105.36696 30.5191,105.36566 30.5307,105.37556 30.5366,105.37856 30.5463,105.39996 30.5439,105.39976 30.5569,105.40886 30.5704,105.41676 30.567))";
				var pxx = "POLYGON((105.68811 30.92987,105.70129 30.91431,105.72913 30.90771,105.73907 30.89209,105.73688 30.88232,105.72589 30.87952,105.7309 30.86713,105.7431 30.85468,105.75568 30.85071,105.75732 30.84192,105.77588 30.82672,105.77948 30.81628,105.79309 30.80188,105.78528 30.7901,105.77649 30.78387,105.78333 30.76129,105.77869 30.7525,105.79028 30.73889,105.79028 30.71173,105.79852 30.7085,105.80029 30.69849,105.79529 30.69128,105.8103 30.65149,105.80188 30.64148,105.8031 30.63129,105.82031 30.62549,105.82068 30.6037,105.82849 30.59912,105.8349 30.58673,105.86047 30.56653,105.87292 30.5603,105.87408 30.5481,105.86871 30.54388,105.85687 30.51593,105.84308 30.50873,105.84448 30.49213,105.85571 30.48651,105.8587 30.49933,105.87927 30.49969,105.88647 30.48792,105.88129 30.47589,105.87091 30.47211,105.88208 30.46149,105.89148 30.46667,105.90088 30.4621,105.92029 30.47009,105.92609 30.4823,105.93671 30.48749,105.9455 30.48212,105.94531 30.4989,105.92468 30.49628,105.91229 30.5141,105.93011 30.52087,105.9389 30.50653,105.94928 30.50427,105.95508 30.51172,105.96948 30.48889,105.96753 30.48053,105.97131 30.47229,105.96411 30.45532,105.95007 30.45911,105.94409 30.44812,105.95728 30.43048,105.9671 30.43451,105.9729 30.43091,105.97467 30.41949,105.98389 30.41632,105.98889 30.3941,105.99731 30.37909,105.98828 30.37189,105.97992 30.37811,105.9715 30.37549,105.96252 30.38171,105.93988 30.37488,105.93732 30.38269,105.92212 30.38812,105.9137 30.39893,105.89807 30.3891,105.89587 30.40851,105.87451 30.40448,105.8833 30.39551,105.87451 30.38953,105.87128 30.40289,105.86047 30.41309,105.84271 30.39532,105.83569 30.40253,105.84271 30.41388,105.83032 30.42169,105.8241 30.43652,105.81671 30.44031,105.79871 30.43073,105.7793 30.4057,105.76831 30.40668,105.75671 30.38751,105.75049 30.39612,105.75427 30.40869,105.75208 30.41809,105.74048 30.41412,105.72491 30.40271,105.7135 30.39832,105.70612 30.41852,105.69708 30.42328,105.6925 30.4375,105.68451 30.44629,105.67371 30.4483,105.6615 30.44031,105.6463 30.43909,105.64172 30.44873,105.65411 30.45892,105.65228 30.46851,105.6571 30.47852,105.67169 30.48468,105.66968 30.4939,105.67407 30.51111,105.6825 30.51868,105.70428 30.50488,105.70972 30.54211,105.7041 30.55371,105.7049 30.56348,105.71588 30.56689,105.71552 30.58411,105.73389 30.60052,105.7359 30.61029,105.7323 30.61871,105.73169 30.64032,105.72211 30.6449,105.70813 30.65851,105.7005 30.64069,105.68347 30.63708,105.67969 30.62732,105.66827 30.62469,105.66272 30.63348,105.65167 30.62708,105.64771 30.61987,105.63489 30.62207,105.62592 30.61853,105.59888 30.63867,105.56708 30.62012,105.55048 30.63013,105.54169 30.63989,105.52368 30.64008,105.51648 30.65167,105.50787 30.64551,105.49847 30.65289,105.48907 30.64752,105.4881 30.64972,105.48413 30.66748,105.47388 30.67468,105.46228 30.6759,105.45209 30.66492,105.4389 30.6601,105.43329 30.6709,105.45428 30.6803,105.45068 30.68988,105.43329 30.69629,105.43988 30.71307,105.43591 30.72913,105.44531 30.72949,105.45868 30.73633,105.4715 30.73309,105.47791 30.74469,105.48688 30.75049,105.50732 30.7569,105.51611 30.75409,105.52631 30.7677,105.51288 30.77631,105.5119 30.78229,105.53571 30.79108,105.54248 30.80511,105.55328 30.80487,105.56671 30.80908,105.55011 30.82373,105.55731 30.82867,105.56348 30.82233,105.5733 30.8407,105.57568 30.85352,105.58087 30.85449,105.58472 30.87512,105.5921 30.88348,105.59387 30.9071,105.60107 30.9071,105.60687 30.91992,105.62128 30.91388,105.62567 30.91949,105.64691 30.92871,105.6535 30.92688,105.65869 30.91852,105.66589 30.92749,105.68811 30.92987))";
				var shx = "POLYGON((105.37886 31.1546,105.37656 31.1382,105.38296 31.1292,105.38596 31.1142,105.40456 31.0914,105.41316 31.0739,105.42336 31.0796,105.42966 31.0682,105.44046 31.069,105.45236 31.0627,105.47226 31.0656,105.47826 31.0455,105.48686 31.0375,105.51656 31.0294,105.53296 31.0284,105.53656 31.0225,105.55346 31.0105,105.56236 31.0091,105.56906 30.9921,105.58576 30.9859,105.59146 30.9759,105.60116 30.9738,105.61446 30.9788,105.62486 30.9756,105.63966 30.9538,105.64026 30.9487,105.65686 30.943,105.65336 30.9269,105.64676 30.9286,105.62566 30.9194,105.62116 30.9139,105.60686 30.9199,105.60106 30.9071,105.59396 30.907,105.59206 30.8834,105.58466 30.8751,105.58096 30.8544,105.57566 30.8534,105.57326 30.8406,105.56356 30.8222,105.55726 30.8286,105.54996 30.8237,105.56666 30.8091,105.55326 30.8048,105.54246 30.805,105.53556 30.791,105.51176 30.7823,105.51286 30.7763,105.52616 30.7676,105.51606 30.7541,105.50726 30.7568,105.48696 30.7505,105.47776 30.7447,105.47146 30.7331,105.45856 30.7363,105.44516 30.7294,105.43576 30.7291,105.43986 30.713,105.43326 30.6962,105.43266 30.694,105.42366 30.6855,105.40956 30.6784,105.39716 30.6852,105.39166 30.668,105.38136 30.661,105.36366 30.6602,105.36376 30.6401,105.34676 30.6377,105.34816 30.6501,105.32616 30.6593,105.31226 30.6562,105.30606 30.6672,105.29576 30.6646,105.28186 30.6745,105.28436 30.7005,105.26416 30.7098,105.26016 30.6918,105.25616 30.6908,105.24186 30.6697,105.21856 30.6795,105.21006 30.6781,105.20996 30.6899,105.19926 30.6923,105.19496 30.7009,105.20316 30.7102,105.20766 30.7294,105.21576 30.736,105.24056 30.728,105.24826 30.7446,105.25696 30.7432,105.26846 30.7544,105.26426 30.783,105.26476 30.7965,105.26076 30.805,105.25706 30.8278,105.25066 30.8348,105.24206 30.833,105.22876 30.8515,105.22626 30.8783,105.19296 30.8937,105.20326 30.9151,105.19126 30.9189,105.18906 30.9372,105.17286 30.9618,105.18816 30.9647,105.19336 30.9823,105.19206 30.9941,105.18366 31.0063,105.18386 31.0188,105.17916 31.0308,105.17146 31.0368,105.17486 31.0519,105.18616 31.0554,105.19386 31.0677,105.19736 31.0804,105.19056 31.0915,105.19436 31.098,105.20926 31.0988,105.22126 31.1097,105.22646 31.1057,105.24476 31.1068,105.26206 31.1023,105.27616 31.1091,105.28476 31.1034,105.29876 31.1148,105.31466 31.1164,105.32276 31.1218,105.31606 31.1293,105.31936 31.1381,105.33986 31.1271,105.34156 31.1459,105.34946 31.1525,105.35106 31.164,105.37886 31.1546))";
				var dyx = "POLYGON((105.2077 30.72949,105.20331 30.71033,105.19489 30.70093,105.19928 30.69232,105.21008 30.68988,105.21008 30.6781,105.21869 30.6795,105.24188 30.66968,105.25629 30.69092,105.26031 30.69189,105.26428 30.7099,105.28448 30.7005,105.28192 30.6745,105.2959 30.66467,105.30609 30.6673,105.31232 30.65631,105.32629 30.6593,105.34808 30.65009,105.34668 30.6377,105.36389 30.64008,105.36371 30.66028,105.38129 30.66107,105.39172 30.66809,105.39728 30.6853,105.40948 30.67853,105.42371 30.68549,105.43268 30.69409,105.43329 30.69629,105.45068 30.68988,105.45428 30.6803,105.43329 30.6709,105.4389 30.6601,105.45209 30.66492,105.46228 30.6759,105.47388 30.67468,105.48413 30.66748,105.4881 30.64972,105.48907 30.64752,105.48633 30.64032,105.47229 30.6355,105.45129 30.63312,105.44269 30.61572,105.43231 30.61987,105.42249 30.61389,105.41827 30.60352,105.40588 30.59631,105.40869 30.58728,105.40167 30.58331,105.38831 30.56488,105.3999 30.55688,105.40009 30.54388,105.37848 30.54633,105.37549 30.53668,105.36572 30.5307,105.36688 30.5191,105.36029 30.50372,105.35248 30.49591,105.33429 30.4953,105.31891 30.48767,105.31848 30.46252,105.30829 30.45972,105.2937 30.47369,105.27948 30.47711,105.27649 30.4599,105.2569 30.4491,105.23871 30.46191,105.2395 30.47412,105.22369 30.48413,105.20288 30.48511,105.1933 30.47791,105.19312 30.47009,105.18109 30.47192,105.16248 30.46411,105.16388 30.4729,105.14209 30.46393,105.12671 30.44751,105.11328 30.4455,105.10889 30.43512,105.08612 30.43127,105.07129 30.43109,105.0705 30.4447,105.0871 30.44427,105.08789 30.46411,105.07251 30.48468,105.08008 30.48749,105.07208 30.5047,105.06708 30.50671,105.05688 30.5235,105.06671 30.53229,105.06451 30.53809,105.0827 30.55328,105.0863 30.56348,105.0965 30.57727,105.0921 30.58728,105.09991 30.59613,105.10968 30.60028,105.12988 30.62927,105.14868 30.64429,105.14728 30.65332,105.13733 30.65887,105.14069 30.67133,105.1651 30.67828,105.16107 30.68488,105.16791 30.69568,105.1665 30.7085,105.16809 30.7243,105.17908 30.72333,105.19928 30.73431,105.2077 30.72949))";

				var csqsymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new esri.Color([132, 164, 232]), 1), new esri.Color([132, 164, 232, 0.75]));
				var ajqsymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new esri.Color([248, 203, 249]), 1), new esri.Color([248, 203, 249, 0.75]));
				var pxxsymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new esri.Color([173, 209, 255]), 1), new esri.Color([173, 209, 255, 0.75]));
				var shxsymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new esri.Color([255, 173, 173]), 1), new esri.Color([255, 173, 173, 0.75]));
				var dyxsymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new esri.Color([255, 239, 168]), 1), new esri.Color([255, 239, 168, 0.75]));

				var csqgraphic = new esri.Graphic(formateData(csq), csqsymbol);
				var ajqgraphic = new esri.Graphic(formateData(ajq), ajqsymbol);
				var pxxgraphic = new esri.Graphic(formateData(pxx), pxxsymbol);
				var shxgraphic = new esri.Graphic(formateData(shx), shxsymbol);
				var dyxgraphic = new esri.Graphic(formateData(dyx), dyxsymbol);

				borderlayer.add(csqgraphic);
				borderlayer.add(ajqgraphic);
				borderlayer.add(pxxgraphic);
				borderlayer.add(shxgraphic);
				borderlayer.add(dyxgraphic);

				var csqcenter = new esri.geometry.Point(105.585, 30.5054);
				var ajqcenter = new esri.geometry.Point(105.408, 30.3707);
				var pxxcenter = new esri.geometry.Point(105.711, 30.6522);
				var shxcenter = new esri.geometry.Point(105.396, 30.9026);
				var dyxcenter = new esri.geometry.Point(105.26, 30.5799);

				var csqtextsymbol = new esri.symbol.TextSymbol("船山区").setColor(new esri.Color([128, 0, 0])).setAlign(esri.symbol.Font.ALIGN_START).setFont(new esri.symbol.Font("12pt").setWeight(esri.symbol.Font.WEIGHT_BOLD));
				var ajqtextsymbol = new esri.symbol.TextSymbol("安居区").setColor(new esri.Color([128, 0, 0])).setAlign(esri.symbol.Font.ALIGN_START).setFont(new esri.symbol.Font("12pt").setWeight(esri.symbol.Font.WEIGHT_BOLD));
				var pxxtextsymbol = new esri.symbol.TextSymbol("蓬溪县").setColor(new esri.Color([128, 0, 0])).setAlign(esri.symbol.Font.ALIGN_START).setFont(new esri.symbol.Font("12pt").setWeight(esri.symbol.Font.WEIGHT_BOLD));
				var shxtextsymbol = new esri.symbol.TextSymbol("射洪县").setColor(new esri.Color([128, 0, 0])).setAlign(esri.symbol.Font.ALIGN_START).setFont(new esri.symbol.Font("12pt").setWeight(esri.symbol.Font.WEIGHT_BOLD));
				var dyxtextsymbol = new esri.symbol.TextSymbol("大英县").setColor(new esri.Color([128, 0, 0])).setAlign(esri.symbol.Font.ALIGN_START).setFont(new esri.symbol.Font("12pt").setWeight(esri.symbol.Font.WEIGHT_BOLD));

				var csqtextgraphic = new esri.Graphic(formateData(csq), csqtextsymbol);
				var ajqtextgraphic = new esri.Graphic(formateData(ajq), ajqtextsymbol);
				var pxxtextgraphic = new esri.Graphic(formateData(pxx), pxxtextsymbol);
				var shxtextgraphic = new esri.Graphic(formateData(shx), shxtextsymbol);
				var dyxtextgraphic = new esri.Graphic(formateData(dyx), dyxtextsymbol);

				borderlayer.add(csqtextgraphic);
				borderlayer.add(ajqtextgraphic);
				borderlayer.add(pxxtextgraphic);
				borderlayer.add(shxtextgraphic);
				borderlayer.add(dyxtextgraphic);
		}

			
    });
	
	function padLeft(){
        String.prototype.padLeft =
            Number.prototype.padLeft = function (total, pad) {
                return (Array(total).join(pad || 0) + this).slice(-total);
            }
   }
	
	function formateData(wkt) {
		var feature = (new ol.format.WKT()).readFeature(wkt);
		var geojson = (new ol.format.GeoJSON()).writeFeature(feature);
		var polygon = new esri.geometry.Polygon(JSON.parse(geojson).geometry.coordinates);
		return polygon;
	}

});


